#include "stdafx.h"
#include "AdwFactory.h"
#include "vehiclImpl.h"
#include "common.h"
#include "connection_manager.h"
#include "dmsDate.h"
#include "GeoMap.h"
#include "request.h"
#include "request_manager.h"
#include "sklad.h"
#include "SpawnPoint.h"
#include "tparser.h"
#include "vehicle.h"
#include "war_manager.h"
#include "AdwDump.h"
#include <crtdbg.h>

AdwFactory::AdwFactory()
{
	// vehicles
	this->addId(Identifier(typeid(tank).name()));
	this->addId(Identifier(typeid(ltank).name()));
	this->addId(Identifier(typeid(htank).name()));
	this->addId(Identifier(typeid(apc).name()));
	this->addId(Identifier(typeid(sau).name()));
	this->addId(Identifier(typeid(pta).name()));	
	this->addId(Identifier(typeid(truck).name()));
	this->addId(Identifier(typeid(cistern).name()));
	this->addId(Identifier(typeid(train).name()));
	this->addId(Identifier(typeid(train_aaa).name()));
	this->addId(Identifier(typeid(wagon).name()));
	this->addId(Identifier(typeid(railcestern).name()));
	this->addId(Identifier(typeid(platform).name()));
	this->addId(Identifier(typeid(warship).name()));
	this->addId(Identifier(typeid(cargoship).name()));
	this->addId(Identifier(typeid(gun).name()));
	this->addId(Identifier(typeid(aaa).name()));
	this->addId(Identifier(typeid(mobileaaa).name()));
	this->addId(Identifier(typeid(smallaaa).name()));
	this->addId(Identifier(typeid(fuelbunker).name()));
	this->addId(Identifier(typeid(ammobunker).name()));
	this->addId(Identifier(typeid(repairbunker).name()));

	// managers
	this->addId(Identifier(typeid(ConnectionManager).name()));
	this->addId(Identifier(typeid(RequestManager).name()));
	//this->addId(Identifier(typeid(WarManager).name()));
	this->addId(Identifier(typeid(GeoMap).name()));
	this->addId(Identifier(typeid(TParser).name()));
	this->addId(Identifier(typeid(IdManager).name()));
	this->addId(Identifier(typeid(AdwDump).name()));

	// objects
	this->addId(Identifier(typeid(sklad).name()));
	this->addId(Identifier(typeid(SpawnPoint).name()));
	this->addId(Identifier(typeid(group).name()));

	// common classes
	this->addId(Identifier(typeid(CdmsDate).name()));
	this->addId(Identifier(typeid(marker).name()));
	this->addId(Identifier(typeid(road_marker).name()));
	this->addId(Identifier(typeid(vector2).name()));
	this->addId(Identifier(typeid(Weather).name()));
	this->addId(Identifier(typeid(wtypep).name()));
	this->addId(Identifier(typeid(wheightp).name()));
	this->addId(Identifier(typeid(TemplateStaticObject).name()));
	this->addId(Identifier(typeid(AirField).name()));
	this->addId(Identifier(typeid(PlanesMap).name()));
	this->addId(Identifier(typeid(utKey).name()));
	this->addId(Identifier(typeid(gtKey).name()));
	this->addId(Identifier(typeid(UnitTemplate).name()));
	
	this->addId(Identifier(typeid(GroupTemplate).name()));

	this->addId(Identifier(typeid(SpawnPointData).name()));
	this->addId(Identifier(typeid(route_data).name()));
	this->addId(Identifier(typeid(request).name()));
	this->addId(Identifier(typeid(GRQ).name()));
	this->addId(Identifier(typeid(Reqrec).name()));
	this->addId(Identifier(typeid(RouteDesc).name()));
	this->addId(Identifier(typeid(SkladTemplate).name()));
	this->addId(Identifier(typeid(ExternalBridgeInfo).name()));
	this->addId(Identifier(typeid(utColStruct).name()));
}

Identifiable* AdwFactory::create(const Identifier& id)
{
	// vehicles
	if (id.className==typeid(tank).name()) return new tank(0,0,0);
	if (id.className==typeid(ltank).name()) return new ltank(0,0,0);
	if (id.className==typeid(htank).name()) return new htank(0,0,0);
	if (id.className==typeid(apc).name()) return new apc(0,0,0);
	if (id.className==typeid(sau).name()) return new sau(0,0,0);
	if (id.className==typeid(pta).name()) return new pta(0,0,0);
	if (id.className==typeid(truck).name()) return new truck(0,0,0);
	if (id.className==typeid(cistern).name()) return new cistern(0,0,0);
	if (id.className==typeid(train).name()) return new train(0,0,0);
	if (id.className==typeid(train_aaa).name()) return new train_aaa(0,0,0);
	if (id.className==typeid(wagon).name()) return new wagon(0,0,0);
	if (id.className==typeid(railcestern).name()) return new railcestern(0,0,0);
	if (id.className==typeid(platform).name()) return new platform(0,0,0);
	if (id.className==typeid(warship).name()) return new warship(0,0,0);
	if (id.className==typeid(cargoship).name()) return new cargoship(0,0,0);
	if (id.className==typeid(gun).name()) return new gun(0,0,0);
	if (id.className==typeid(aaa).name()) return new aaa(0,0,0);
	if (id.className==typeid(mobileaaa).name()) return new mobileaaa(0,0,0);
	if (id.className==typeid(smallaaa).name()) return new smallaaa(0,0,0);
	if (id.className==typeid(fuelbunker).name()) return new fuelbunker(0,0,0);
	if (id.className==typeid(ammobunker).name()) return new ammobunker(0,0,0);
	if (id.className==typeid(repairbunker).name()) return new repairbunker(0,0,0);

	// managers
	if (id.className==typeid(ConnectionManager).name()) return new ConnectionManager(0,0,0);
	if (id.className==typeid(RequestManager).name()) return new RequestManager(0,0,0);
	//if (id.className==typeid(WarManager).name()) return new WarManager();
	if (id.className==typeid(GeoMap).name()) return new GeoMap(0,0,0);
	if (id.className==typeid(TParser).name()) return new TParser(0,0,0);
	if (id.className==typeid(IdManager).name()) return new IdManager(0,0,0);
	if (id.className==typeid(AdwDump).name()) return new AdwDump(0,0,0);

	// objects
	if (id.className==typeid(sklad).name()) return new sklad(0,0,0);
	if (id.className==typeid(SpawnPoint).name()) return new SpawnPoint(0,0,0);
	if (id.className==typeid(group).name()) return new group(0,0,0);

	// common classes
	if (id.className==typeid(CdmsDate).name()) return new CdmsDate(false,false,false);
	if (id.className==typeid(marker).name()) return new marker(false,false,false);
	if (id.className==typeid(road_marker).name()) return new road_marker(false,false,false);
	if (id.className==typeid(vector2).name()) return new vector2(0,0,0);
	if (id.className==typeid(Weather).name()) return new Weather(0,0,0);
	if (id.className==typeid(wtypep).name()) return new wtypep(0,0,0);
	if (id.className==typeid(wheightp).name()) return new wheightp(0,0,0);
	if (id.className==typeid(TemplateStaticObject).name()) return new TemplateStaticObject(0,0,0);
	if (id.className==typeid(AirField).name()) return new AirField(0,0,0);
	if (id.className==typeid(PlanesMap).name()) return new PlanesMap(0,0,0);
	if (id.className==typeid(utKey).name()) return new utKey(false,false,false);

	if (id.className==typeid(gtKey).name()) return new gtKey(false,false,false);
	
	if (id.className==typeid(UnitTemplate).name()) return new UnitTemplate(0,0,0);
	if (id.className==typeid(GroupTemplate).name()) return new GroupTemplate(0,0,0);
	if (id.className==typeid(SpawnPointData).name()) return new SpawnPointData(0,0,0);
	if (id.className==typeid(route_data).name()) return new route_data(0,0,0);
	if (id.className==typeid(request).name()) return new request(false,false,false);
	if (id.className==typeid(GRQ).name()) return new GRQ(false,false,false);
	if (id.className==typeid(Reqrec).name()) return new Reqrec(0,0,0);
	if (id.className==typeid(RouteDesc).name()) return new RouteDesc(0,0,0);
	if (id.className==typeid(SkladTemplate).name()) return new SkladTemplate(0,0,0);
	if (id.className==typeid(ExternalBridgeInfo).name()) return new ExternalBridgeInfo(0,0,0);
	if (id.className==typeid(utColStruct).name()) return new utColStruct(false,false,false);
	
	_ASSERTE(false);

	return 0;
}